﻿using BenCaoXuan.Infrastructure.Attr;
using BenCaoXuan.Infrastructure.Dto;
using BenCaoXuan.Infrastructure.Dto.Middle.Request.Appointment;
using BenCaoXuan.Infrastructure.Dto.Middle.Request.ProductPackage;
using BenCaoXuan.Infrastructure.Dto.Middle.Request.Register;
using BenCaoXuan.Service.Interface.middle;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Mysqlx.Crud;

namespace BenCaoXuan.Api.Admin.Controllers.middle
{
    [ApiGroup("Middle(移动端模块)")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductController : ControllerBase
    {
        private readonly I_MiddleProduct_Service _middleProduct_Service;

        public ProductController(I_MiddleProduct_Service middleProduct_Service)
        {
            _middleProduct_Service = middleProduct_Service;
        }
            /// <summary>
            /// 获取所有产品
            /// </summary>
            /// <returns></returns>
            [HttpGet]
        public async Task<IActionResult> Get_All_Products()
        {
            var result=await _middleProduct_Service.Get_All_Products();
            return Ok(result);
        }
        /// <summary>
        /// 根据套餐ID查询套餐下的所有产品
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Get_Products(string? id)
        {
            var result = await _middleProduct_Service.Get_Products(id);
            return Ok(result);
        }
        /// <summary>
        /// 获取所有的产品套餐
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_All_Product_Package(int page = 1, int limit = 10, string key = "")
        {
            var result = await _middleProduct_Service.Get_All_Product_Package(new Fenye_Dto()
            {
                page = page,
                limit = limit,
                key = key
            });
            return Ok(result);
        }
        /// <summary>
        /// 获取单个产品套餐
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Get_Single_Product_Package([FromQuery] string? id)
        {
            var result = await _middleProduct_Service.Get_Single_Product_Package(id);
            return Ok(result);
        }
        }
}
